﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogicCircuit
{
    [Serializable]
    public class Connection
    {
        public Element supplier;
        public Element target;

        public Connection(Element sup, Element tar)
        {
            supplier = sup;
            target = tar;
        }
        public int Value
        {
            get
            {
                if (supplier != null)
                {
                    if (supplier.GetType() == typeof(Source))
                        return ((Source)supplier).Output;
                    else if (supplier.GetType() == typeof(And))
                        return ((And)supplier).Output;
                    else if (supplier.GetType() == typeof(Or))
                        return ((Or)supplier).Output;
                    else if (supplier.GetType() == typeof(Not))
                        return ((Not)supplier).Output;
                    else
                        return -1;
                }
                else
                    return -1;
            }
        }
    }
}
